@page
@model ContosoUniversity.Pages.Instructors.CreateModel

@{
    ViewData["Title"] = "Create";
}

<h2>Create</h2>

<h4>Instructor</h4>
<hr />
<div class="row">
    <div class="col-md-4">
        <form method="post">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <div class="form-group">
                <label asp-for="Instructor.LastName" class="control-label"></label>
                <input asp-for="Instructor.LastName" class="form-control" />
                <span asp-validation-for="Instructor.LastName" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Instructor.FirstMidName" class="control-label"></label>
                <input asp-for="Instructor.FirstMidName" class="form-control" />
                <span asp-validation-for="Instructor.FirstMidName" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Instructor.HireDate" class="control-label"></label>
                <input asp-for="Instructor.HireDate" class="form-control" />
                <span asp-validation-for="Instructor.HireDate" class="text-danger"></span>
            </div>
                <div class="form-group">
                    <label asp-for="Instructor.OfficeAssignment.Location" class="control-label"></label>
                    <input asp-for="Instructor.OfficeAssignment.Location" class="form-control" />
                    <span asp-validation-for="Instructor.OfficeAssignment.Location" class="text-danger" />
                </div>
                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <table>
                            <tr>
                                @{
                                    int cnt = 0;

                                    foreach (var course in Model.AssignedCourseDataList)
                                    {
                                        if (cnt++ % 3 == 0)
                                        {
                                            @:</tr><tr>
                                        }
                                        @:<td>
                                            <input type="checkbox"
                                                   name="selectedCourses"
                                                   value="@course.CourseID"
                                                   @(Html.Raw(course.Assigned ? "checked=\"checked\"" : "")) />
                                                   @course.CourseID @:  @course.Title
                                        @:</td>
                                    }
                                    @:</tr>
                                }
                        </table>
                    </div>
                </div>
            <div class="form-group">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </form>
    </div>
</div>

<div>
    <a asp-page="Index">Back to List</a>
</div>

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
